package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YxDeviceUseableTime;
import com.ruoyi.system.service.IYxDeviceUseableTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备可用日期Controller
 * 
 * @author lingyu
 * @date 2024-03-11
 */
@RestController
@RequestMapping("/system/deviceUseableTime")
public class YxDeviceUseableTimeController extends BaseController
{
    @Autowired
    private IYxDeviceUseableTimeService yxDeviceUseableTimeService;

    /**
     * 查询设备可用日期列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceUseableTime:list')")
    @GetMapping("/list")
    public TableDataInfo list(YxDeviceUseableTime yxDeviceUseableTime)
    {
        startPage();
        List<YxDeviceUseableTime> list = yxDeviceUseableTimeService.selectYxDeviceUseableTimeList(yxDeviceUseableTime);
        return getDataTable(list);
    }

    /**
     * 导出设备可用日期列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceUseableTime:export')")
    @Log(title = "设备可用日期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YxDeviceUseableTime yxDeviceUseableTime)
    {
        List<YxDeviceUseableTime> list = yxDeviceUseableTimeService.selectYxDeviceUseableTimeList(yxDeviceUseableTime);
        ExcelUtil<YxDeviceUseableTime> util = new ExcelUtil<YxDeviceUseableTime>(YxDeviceUseableTime.class);
        util.exportExcel(response, list, "设备可用日期数据");
    }

    /**
     * 获取设备可用日期详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceUseableTime:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yxDeviceUseableTimeService.selectYxDeviceUseableTimeById(id));
    }

    /**
     * 新增设备可用日期
     */
    @PreAuthorize("@ss.hasPermi('system:deviceUseableTime:add')")
    @Log(title = "设备可用日期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YxDeviceUseableTime yxDeviceUseableTime)
    {
        return toAjax(yxDeviceUseableTimeService.insertYxDeviceUseableTime(yxDeviceUseableTime));
    }

    /**
     * 修改设备可用日期
     */
    @PreAuthorize("@ss.hasPermi('system:deviceUseableTime:edit')")
    @Log(title = "设备可用日期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YxDeviceUseableTime yxDeviceUseableTime)
    {
        return toAjax(yxDeviceUseableTimeService.updateYxDeviceUseableTime(yxDeviceUseableTime));
    }

    /**
     * 删除设备可用日期
     */
    @PreAuthorize("@ss.hasPermi('system:deviceUseableTime:remove')")
    @Log(title = "设备可用日期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yxDeviceUseableTimeService.deleteYxDeviceUseableTimeByIds(ids));
    }
}
